package com.plm.k8s.myk8sapi.cmd;

import com.plm.k8s.myk8sapi.pojo.entity.deployment.DeploymentEntity;
import com.plm.k8s.myk8sapi.pojo.entity.pod.*;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * 处理deployment相关的命令
 */
public interface IDeploymentCmd {

    /**
     * 罗列出所有的deploy信息
     * @param isAll
     * @param namespace
     * @param nameFilter
     * @param labelFilter
     * @return
     */
    List<DeploymentEntity> listDeployments(boolean isAll, String namespace, String nameFilter,
            Map<String, String> labelFilter) throws Exception;

    /**
     * 根据yaml文件创建deployment控制器
     * @param yamlFile
     * @return
     * @throws Exception
     */
    boolean createDeployment(File yamlFile) throws Exception;

    /**
     * 创建deployment控制器
     * @param name
     * @param image
     * @param replicas
     * @param envs
     * @param ports
     * @param volumeMounts
     * @param volumes
     * @param namespace
     * @param terminationGracePeriodSeconds
     * @param command
     * @param startupProbe
     * @param livenessProbe
     * @param readinessProbe
     * @param lifecycle
     * @return
     * @throws Exception
     */
    boolean createDeployment(String name, String image, Integer replicas, String imagePullPolicy, List<PodSpecContainerEnvEntity> envs,
            List<PodSpecContainerPortEntity> ports, List<PodSpecContainerVolumeMountEntity> volumeMounts,
            List<PodSpecVolumeEntity> volumes, String namespace, Integer terminationGracePeriodSeconds,
            List<String> command, PodSpecContainerStartupProbeEntity startupProbe,
            PodSpecContainerLivenessProbeEntity livenessProbe, PodSpecContainerReadinessProbeEntity readinessProbe,
            PodSpecContainerLifecycleEntity lifecycle, PodSpecContainerResourcesRequestsEntity requests,
            PodSpecContainerResourcesLimitsEntity limits) throws Exception;

    /**
     * 删除deployment控制器
     * @param name
     * @param namespace
     * @param force
     * @return
     */
    boolean deleteDeployment(String name, String namespace, boolean force) throws Exception;

    /**
     * 对控制器进行
     * @param name
     * @param replicas
     * @param namespace
     * @return
     * @throws Exception
     */
    boolean scaleDeployment(String name, Integer replicas, String namespace) throws Exception;
}
